import mockjs from 'mockjs';

let dataList = mockjs.mock({
  code: 200,
  msg: '学员列表加载成功',
  'data|111': [
    {
      'personId|+1': 1,
      name: '@cname',
      score: '@integer(50,100)',
      city: '@city',
      time: '@date',
      pic: '@image',
    },
  ],
});

export default {
  // 支持值为 Object 和 Array
  'GET /class/stu': dataList,

  'DELETE /class/stu': (req, res) => {
    //   console.log('+++++++++++====',req.query)
    //  console.log(dataList)
    let { id } = req.query;
    for (let i = 0; i < dataList.data.length; i++) {
      if (dataList.data[i].personId == id) {
        dataList.data.splice(i, 1);
        res.send({
          code: 200,
          msg: '删除成功',
        });

        return;
      }
    }

    res.send({
      code: 100,
      mas: '未找到对应数据',
    });
  },
};
